﻿/*
 * Created by SharpDevelop.
 * User: jbrinega
 * Date: 1/30/2013
 * Time: 11:54 AM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Xml; 
using System.Xml.XPath; 
using System.Xml.Xsl; 



namespace AdminDesktop.Controls
{
	/// <summary>
	/// Description of ucReportViewer.
	/// </summary>
	public partial class ucReportViewer : UserControl
	{
		public ucReportViewer()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			this.Dock= DockStyle.Fill;
		}
		
		public void LoadReport(string xslReport)
		{
			this.Visible=true;
			XPathDocument myXPathDoc = new XPathDocument(DataEngine.GetDataStream());
			XslCompiledTransform myXslTrans = new XslCompiledTransform();
			myXslTrans.Load(xslReport);
			XmlTextWriter myWriter = new XmlTextWriter(@"c:\result.html",null) ;
 			myXslTrans.Transform(myXPathDoc,null,myWriter) ;
 			
 			//if(this.webBrowser1.IsDisposed) {this.webBrowser1=new WebBrowser();}
 			this.webBrowser1.Navigate(@"c:\result.html");
 			myWriter.Close();
		}
		
		void BtnPrintClick(object sender, EventArgs e)
		{
			DialogResult result = MessageBox.Show("Make sure legal size paper is in the printer.",Application.ProductName,MessageBoxButtons.OKCancel,MessageBoxIcon.Information);
			if(result== DialogResult.OK)
			{
				
				this.webBrowser1.ShowPrintDialog();
				//this.webBrowser1.Print();
			}
		}
		
		void BtnCloseClick(object sender, EventArgs e)
		{
			this.Visible=false ;
		}
	}
}
